#ifndef __CAL_YLD_H__
#define __CAL_YLD_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int add(int, int);
int sub(int, int);
int mul(int, int);
int div_h__(int, int);
void err_exit(char *); 
void exce();
void getsym(char *, void *, void *); 

typedef int (*fun)(int, int);

char expr[BUFSIZ] = "(1+2)*3";
char *expr_end = expr;
int n_stack[BUFSIZ];
int *n_p = n_stack;
int o_stack[BUFSIZ];
int *o_p = o_stack;
enum TYPE {NUM, OPT, LPAR, RPAR} xxtype;
enum OPTT {ADD, SUB, MUL, DIV} xxoptt;
fun f[4] = {add, sub, mul, div_h__};
int o2n[4] = {ADD, SUB, MUL, DIV};
int pri[4] = {0, 0, 1, 1}; 

#define IS_OEMPTY       (o_p == o_stack)
#define PVAL            128
#define PUSHO(x)        (*o_p++ = x)
#define POPO(x)         ((o_p)==(o_stack)||((o_p[-1])==PVAL)? \
                        ((x) = (-1)):((x) = (*--o_p)))
#define PUSHN(x)        (*n_p++ = x)
#define POPN(x)         ((x) = (*--n_p))
#define CMPO(l, r)      (pri[l]-pri[r])
#define CALL            (*o_p++ = PVAL)
#define O2N(sym)        (!strcmp(sym, "+")? ADD:\
                        !strcmp(sym, "-")? SUB:\
                        !strcmp(sym, "*")? MUL: DIV)


#endif